package cn.edu.scau.cmi.huangxiaodong.adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class AdapterOfObject  implements 	Target {
		
			@Override
			public List sortStudent(List<Student> studentList) {
				   List<Integer> idList=new ArrayList<>();;
				    List<Student>list=new ArrayList<>();	  
				    if(studentList.isEmpty()) {
				    	return null;
				    }
				    for(int i=0;i<studentList.size();i++) {
				    	Student student=studentList.get(i);
				    	idList.add(student.getId());
				    }
				    SortUtil sortUtil=new  SortUtil();
		            idList=sortUtil.sortInt(idList);	          
		            list.clear();   
		            if(list.isEmpty()) {
		            Student stu;
		           int  count=idList.size();
		            for(int i=0;i<count;i++) {           	
		            	for(int j=0;j<count;j++) {
		            		stu=studentList.get(j);
		            		if(idList.get(i)==stu.getId()) {
		            			list.add(stu);
		            			break;
		            		}
		            	}                   	
		            }       
		        }
		            studentList.clear();
		            if(studentList.isEmpty()) {
		            	   int  count=idList.size();
		            	for(int i=0;i<count;i++) {
		            		Student stu=list.get(i);
		            		studentList.add(stu);
		            	}
		            }
		        
				return studentList;
			}
	      
	}


